package com.wangzeqi.neihanduanzi.home;

import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Adapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.wangzeqi.neihanduanzi.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/1/8.
 */
public class HomeAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> data;
    private Context context;

    String list1 = "推荐";
    String list2 = "视频";
    String list3 = "图片";
    String list4 = "段子";
    String list5 = "文章";
    String list6 = "精华";
    String list7 = "同城";
    String list8 = "段友圈";

    String[] lists = {list1, list2, list3, list4, list5, list6, list7, list8};

    public HomeAdapter(FragmentManager fm, ArrayList<Fragment> data, Context context) {
        super(fm);
        this.data = data;
        this.context = context;
    }


    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return lists[position];
    }

    public View getTabView(int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_tab, null);
        TextView textView = (TextView) view.findViewById(R.id.tab_text);
        textView.setText(lists[position]);
        return view;
    }

}
